<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>云支付账号</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  #parse('/headFiles.html')
</head>
<body>
<div class="layui-fluid">
    <div class="layui-form">
        <input type="hidden" name="receivingId"/>
        <input type="hidden" name="receivingType"/>
        <input type="hidden" name="receivingPhone"/>
        <div class="layui-row">
            <div class="layui-col-sm5">
                <div class="layui-form-item">
                    <label class="layui-form-label">取款金额</label>
                    <div class="layui-input-block">
                        <input type="text" name="money" lay-verify="required"  autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-col-sm5">
                <div class="layui-form-item">
                    <label class="layui-form-label">真实姓名</label>
                    <div class="layui-input-block">
                        <input type="text" name="receivingName" lay-verify="required"  autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-col-sm2" style="text-align:center;">
                <input type="button" class="layui-btn" lay-submit lay-filter="LAY-form-submit" id="LAY-form-submit" value="提交">
            </div>
        </div>
        <div class="layui-card">
            <div class="layui-card-header">
                <button type="button" class="layui-btn layui-btn-sm layui-btn-fun" data-type="addWithdrawPayee">新增取款用户</button>
            </div>
            <div class="layui-card-body">
                <table id="LAY-withdraw-payee-list" lay-filter="LAY-withdraw-payee-list"></table>
            </div>
        </div>
    </div>
</div>
#parse('/footFiles.html')
<script type="text/javascript">
 layui.config({
    base: '$!{webRoot}/layuiadmin/' //静态资源所在路径
    ,webRoot:'$!{webRoot}'
 }).extend({
    index: 'lib/index'
 }).use(['index', 'table','form'], function(){
    var $ = layui.$,form = layui.form,table = layui.table;

    table.render({
         elem: '#LAY-withdraw-payee-list'
         ,url: '$!{webRoot}/business/payAccount/withdraw/payee/list.data'
         ,method: 'post'
         ,parseData: function(res){
             return {
                 "code": res.code,
                 "msg": res.msg,
                 "count": res.body.total,
                 "data": res.body.data
             };
         }
         ,response: {statusCode: 200}
         ,cols: [[
             {type:'radio',field:'receivingId',title: '选择'}
             ,{field:'receivingId', title: '收款人ID'}
             ,{field:'receivingNickname', title: '收款人昵称'}
             ,{field:'receivingPhone', title: '收款人电话'}
             ,{field:'receivingTypeName', title: '收款人类型'}
             ,{field:'receivingAppId', title: '收款应用ID'}
             ,{field:'createDate', title: '创建时间'}
         ]]
         ,page: false
         ,height: 'full-220'
     });

     table.on('radio(LAY-withdraw-payee-list)', function(obj){
         console.log(obj);
         if(obj.checked) {
             $('input[name="receivingId"]').val(obj.data.receivingId);
             $('input[name="receivingType"]').val(obj.data.receivingType);
             $('input[name="receivingPhone"]').val(obj.data.receivingPhone);
         }else{
             $('input[name="receivingId"]').val('');
             $('input[name="receivingType"]').val('');
             $('input[name="receivingPhone"]').val('');
         }
     });

     form.on('submit(LAY-form-submit)', function(data){
         var field = data.field;
         var waitIndex = layer.load({

         });
         $.ajax({
             type: "post",
             url: "$!{webRoot}/business/payAccount/withdraw.do",
             data: field,
             dataType: "json",
             success: function (res) {
                 layer.close(waitIndex);
                 if (res.code == 200) {
                     layer.msg('取款申请成功', {icon: 1});
                 } else {
                     layer.msg(res.msg, {icon: 2});
                 }
             }
         });
         return false;
     });

     var active = {
         addWithdrawPayee: function(obj){
             layer.open({
                 type: 2
                 ,title: '新增取款用户'
                 ,content: layui.setter.webRoot + '/business/payAccount/withdraw/payee/add.html'
                 ,maxmin: false
                 ,area: ['450px', '450px']
                 ,btn: [ '取消']
                 ,end:function (){
                     table.reload('LAY-withdraw-payee-list');
                 }
             });
         }
     }

     $('.layui-btn.layui-btn-fun').on('click', function(){
         var type = $(this).data('type');
         active[type] ? active[type].call(this) : '';
     });
});
</script>
</body>
</html>